Skip to content

fix: drain in-flight responses on stdin EOF#759

Merged
DaleSeo merged 1 commit intomainfrom
fix/drain-inflight-responses-on-eof
Mar 18, 2026
Merged

fix: drain in-flight responses on stdin EOF#759
DaleSeo merged 1 commit intomainfrom
fix/drain-inflight-responses-on-eof

Conversation

@DaleSeo
Copy link
Member

@DaleSeo DaleSeo commented Mar 17, 2026

Fixes #753

Motivation and Context

This PR adds a drain phase between the main loop exit and transport.close(). It also changes response send tasks from fire-and-forget tokio::spawn to a tracked JoinSet, so we can wait for sends already dispatched by the main loop before draining any remaining handler responses from the channel. A configurable timeout (5s for Closed, 2s for Cancelled) prevents hanging on stuck handlers. The drain is skipped entirely for JoinError quit reasons.

How Has This Been Tested?

Added new integration tests.

Breaking Changes

None. The drain phase is purely additive.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@github-actions github-actions bot added T-test Testing related changes T-core Core library changes labels Mar 17, 2026
@DaleSeo DaleSeo self-assigned this Mar 17, 2026
@DaleSeo DaleSeo marked this pull request as ready for review March 17, 2026 17:29
@DaleSeo DaleSeo requested a review from a team as a code owner March 17, 2026 17:29
@DaleSeo DaleSeo merged commit 251ebec into main Mar 18, 2026
16 checks passed
@DaleSeo DaleSeo deleted the fix/drain-inflight-responses-on-eof branch March 18, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stdio server drops in-flight tool responses when stdin closes

2 participants